import axios from "axios";

//二次封装axios
let Request = {
  //获取参数地址 传参  请求方法
  getData({url,data={},method="get"}){
    return new Promise((resolve,reject) => {
      this._getReq(url,method,data,resolve,reject)
    })
  },
  _getReq:function(url,method="get",data={},resolve,reject){
    let format = method=="get"?"params":"data";
    axios({
      url:url,
      method:method,
      [format]:data,
    }).then(res => {
      resolve(res)
    }).catch(() => {
      reject();
    })
  }
}
export { Request }
